<!DOCTYPE html>
<%@ taglib uri="control" prefix="ef"%>
<ef:priv/>
<ef:init method="Application.init">
<html xmlns="http://www.w3.org/1999/xhtml" style="overflow: hidden">
<!-- Head -->
<head>
    <meta charset="utf-8" />
    <title>${AppName}-${Title}</title>
    <meta name="description" content="安环家综合应用系统" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" href="bootstrap/img/favicon.png" type="image/x-icon">
    <link href="vendor/miniui/themes/material/miniui.css" rel="stylesheet" />
    <link href="framework/css/app.min.1.css" rel="stylesheet" type="text/css" />
    <link href="framework/css/app.min.2.css" rel="stylesheet" type="text/css" />
    <link href="framework/css/application.css" rel="stylesheet" type="text/css" />
    <ef:if condition="${CssFile!=''}">
    	<link href="framework/skins/${CssFile}.min.css" rel="stylesheet" type="text/css" />
    </ef:if>
    <script src="ucenter/main.js"></script>
    <style>body{min-width:1000px;min-height:400px}html, html body {padding:0;border:0;margin:0;width:100%;height:100%;overflow:hidden;}</style>
    <script type="text/javascript">
    	$(function(){
    		mini.Cookie.set("_app", '${AppID}', 365);
    		mini.Cookie.set("_skin", '${CssFile}', 365);
    		var content = mini.byClass("page-content");
    		content.style.height = (document.documentElement.clientHeight - 45) + "px";
    		$(window).bind('resize', function() {
        		content.style.height = (document.documentElement.clientHeight - 45) + "px";
    		});
    		$('#setting-toggler').on('click', function (e) {
    			$('#setting-toggler').addClass("active");
    			mini.open({
    				width:800,
    				height:500,
    				title:'@{Platform.UserSetting}：${User.UserName}',
    				url:'${ctx}platform/userSettingTabs.jhtml',
    				onOk:function(){
    					$DW.save();
    				}
    			});
			});
			$('#mail-toggler').on('click', function (e) {
    			$('#setting-toggler').addClass("active");
    			mini.open({
    				width:900,
    				height:500,
    				title:'@{Platform.ShortMessageList}',
    				url:'${ctx}platform/message/message.jhtml',
    				onLoad:getNewMessageCount
    			});
			});
			//处理是否有可用的应用
			if($('#app_select_area').find('li').length == 0){ //没有备选的应用
				$('#search-toggler').hide();//隐藏搜索功能
				$('.navbar-more-btnwrap').hide();//隐藏应用选择区域
				$('.navbar .navbar-brand').css('cursor', 'default');
				if($('#main-menu').find('a').length == 0){//当前没有可用的应用
					$('.navbar .navbar-brand h1').html('无应用可用');
					$('#sidebar').hide();//隐藏左侧菜单
				}
			} else {
				$('#search-toggler').on('click', function (e) {
	    			$('.navbar-inner').addClass('search-toggled');
				});
				$('#top-search-close').on('click', function (e) {
	    			$('.navbar-inner').removeClass('search-toggled');
				});
			}
    	});
    	function changeApp(appID){
    		mini.Cookie.set("_app", appID);
    		var hash = "";
    		Server.sendRequest("Application.lastMenu",{app:appID},function(response){
    			if(response.Status == 1){
    				hash = "#" + response.Message;	
    			}
    			window.location.href = "start?app=" + appID + hash;
    		});
    	}
    	
    	function showLocker(){
    		var lockerWrap = mini.byId("lockerWrap");
			lockerWrap.style.zIndex = mini.zindex();
			$('#lockerWrap').show();
    		var locker = mini.byId("lock-container");
			locker.style.left = (document.documentElement.clientWidth - $('#lock-container').outerWidth())/2 + 'px';
			locker.style.zIndex = mini.zindex();
			$('#lock-container').show();
			$('#Password').focus().select()
			stopGetMessage();//停止获取新邮件
    	}
    	
    	//解锁窗口
    	function unLock(){
    		Server.sendRequest("Login.submit", {UserName:'${User.UserName}',Password:$('#unlock_password').val()}, function(response){
             	if(response.Status == 1){
             		$('#lock-container').hide();
             		$('#lockerWrap').hide();
             		timeoutID = setTimeout(getNewMessageCount, 1000*30);
             	} else {
             		mini.alert(response.Message);
             	}
             });
    	}
    	
    	var timeoutID = 0;

    	Page.onReady(function(){
    		if (Notification.permission!=='granted') {
        		Notification.requestPermission();    //否则弹出开启权限提示框
			}
    		var timer;
    		function startTimer(){clearTimeout(timer);timer=setTimeout(function(){
    			if($('#lockerWrap').css('display') == 'none'){showLocker();changeStatus('away')}
    		}, 50*60*1000);}
    		document.onmousemove = document.onmousedown = document.onkeydown = document.onkeypress = startTimer;
    		timeoutID = setTimeout(getNewMessageCount, 1000*30);
    	});
    	
    	//获取短消息
    	function getNewMessageCount(){
    		var dc = {SessionID:"${SessionID}"};
    		Server.sendRequest("Message.getNewMessage",dc,function(response){
    			var count = response.Count;
    			if(count > 0){
    				$('#unread-message-count').show();
        			$('#unread-message-count').html(count);
    			} else{
    				$('#unread-message-count').hide();
    			}	
    			<ef:if condition="${'N'!=Config.PopupMessageFlag}">
    			if(response.PopFlag=="Y"){
        			top.mini.showTips({content:response.Message,timeout:99999});
    			}
    			if(response.LogoutFlag!="Y"){
    				timeoutID = setTimeout(getNewMessageCount, 1000*30);
    			}
    			</ef:if>
    		},null,true,'json');//true表示不需要session，否则页面打开后即会永不失效
    	}

    	function stopGetMessage(){
    		clearTimeout(timeoutID);
    	}
    	
    	//刷新会话列表
    	function getChartList(){
    		Server.sendRequest("Chart.getList", function(response){
    			if(response.Status == 1){
    				var html = '';
    				var list = response.list;
    				list.each(function(){
    					html += '<li class="contact" id="chart_li_' + this.UserName + '"><div class="contact-avatar"><img src="';
    					html += this.avatar + '/></div><div class="contact-info"><div class="contact-name">' + this.RealName + '</div><div class="contact-status"><div class="' + this.UserStatus + '"></div></div>';
    					html += '<div class="last-chat-time">' + this.LastChartTime + '</div></div></li>';
    				});
    				$('#chat_list').html(html);
    			}
    		});
    	}
    	
    	function mailDialog(){
    		var dialog = mini.open({
    			width:800,
    			height:500,
    			url:'platform/changePasswordDialog.jhtml',
    			onOk:function(){
    				alert('11');
    			}
    		});
    	}
    	
    	function changeStatus(status){
    		Server.sendRequest("Application.changeStatus", {Status:status});
    	}
    	<ef:extend id="com.efastsoft.platform.ApplicationScript" />
    </script>
</head>
<!-- /Head -->
<!-- Body -->
<body>
    <!-- Loading Container -->
    <div class="loading-container">
        <div class="loader"></div>
    </div>
    <!--  /Loading Container -->
    <!-- Navbar -->
    <div class="navbar">
        <div class="navbar-inner">
            <div class="navbar-container">
                <!-- Navbar Barnd -->
                <div class="navbar-header pull-left">
					<div class="navbar-more-btnwrap">
						<a class="navbar-more" data-toggle="dropdown" aria-expanded="false" href="#"><span class="navbar-more-icon"></span></a>
	                	<div class="flyout-more" >
							<div class="flyout-more-content">		
								<ul class="c_h_ttl" id="app_select_area">
									<ef:list method="Application.bindApps">
										<ef:if condition="${ID!=AppID}">
											<li><a href="#" id="c_h_${ID}" onclick="changeApp('${ID}')"><span class="is_c" style="background:${Color}"><i class="iconfont ${Icon} is_img"></i></span><span>${Name}</span></a></li>
										</ef:if>
									</ef:list>
								</ul>
							</div>
							<div class="bubbleBeak beak4"></div>
						</div>
					</div>                	
                    <div class="navbar-brand"><h1>${AppName}</h1></div>
                </div>
                <div class="mainMenu" id="main-menu">
					<ef:list method="Application.bindMainMenus">
						<a id='_Menu_${ID}' menuid="${ID}" onclick='return false;' url="${URL}" hidefocus='true' class="topbar_menu"><i class="icon ${IconCls}"></i>${Name}</a>
					</ef:list>
				</div>
                <!-- /Navbar Barnd -->
                <!-- Account Area and Settings --->
                <div class="navbar-header pull-right">
                    <div class="navbar-account">
                        <ul class="account-area">
                            <li class="hide">
                                <a class="wave in" id="chat-link" title="Chat" href="#">
                                    <i class="icon iconfont icon-pingjia"></i>
                                </a>
                            </li>
							<li class="hide">
                                <a title="搜索" id="search-toggler">
                                    <i class="icon iconfont icon-search"></i>
                                </a>
                            </li>
                            <li>
                            	<a class="dropdown-toggle" data-toggle="dropdown" title="短消息" id="mail-toggler">
                                    <i class="icon iconfont icon-mail"></i>
									<span class="badge" style="display:none;" id="unread-message-count">0</span>
                                </a>
                            </li>
                            <li>
                                <a class="dropdown-toggle" data-toggle="dropdown" title="设置" id="setting-toggler">
                                    <i class="icon iconfont icon-system"></i>
                                    <span class="badge"></span>
                                </a>
                            </li>
                            <li>
                                <a class="login-area dropdown-toggle" data-toggle="dropdown" style="width:137px;">
                                    <div class="avatar" title="View your public profile">
                                        <img src="${User.AvatarPrefix}${User.Avatar.P4}.jpg" onerror="this.src='framework/images/avatar.p4.png'">
                                    </div>
                                    <section>
                                        <h2><span class="profile"><span>${User.RealName}</span></span></h2>
                                    </section>
                                </a>
                                <!--Login Area Dropdown-->
                                <ul class="pull-right dropdown-menu dropdown-arrow dropdown-login-area">
                                    <li class="username"><a>${User.RealName}</a></li>
                                    <li class="email" style="border-bottom: 2px solid #CBCBCB;"><a style="line-height: 18px;font-size: 13px;">${User.UserName}</a></li>
                                    <ef:extend id="com.efastsoft.platform.UserProfile" />
                                    <li class="dropdown-footer">
                                        <a href="platform/logout"> <ef:lang id="Application.Logout">注销</ef:lang> </a>
                                    </li>
                                </ul>
                                <!--/Login Area Dropdown-->
                            </li>
                            <!-- /Account Area -->
                            <!--Note: notice that setting div must start right after account area list.
                            no space must be between these elements-->
                            <!-- Settings -->
                        </ul>
                    </div>
                </div>
                <!-- /Account Area and Settings -->
                <!-- search -->
               		<div id="top-search-wrap" class="ng-scope">
               			<div class="search_inner_box clearfix">
				            <div class="selectbox">
				                <input class="mini-combobox" data='[{text:"文档",id:"11"},{text:"秋天",id:"2"}]' showClose="false">
				            </div>
				            <form id="top_nav_form">
				                <input type="text" class="ts_txt fl" placeholder="..." >
				                <i class="iconfont icon-search ts_btn"></i>
				            </form>
				        </div>
				        <a title="关闭搜索" id="top-search-close">
                        	<i class="icon iconfont icon-close"></i>
                        </a>
               		</div>
                <!-- /search -->
            </div>
        </div>
    </div>
    <!-- /Navbar -->
    <!-- Main Container -->
    <div class="main-container container-fluid">
        <!-- Page Container -->
        <div class="page-container">
            <!-- Page Sidebar -->
            <div class="page-sidebar" id="sidebar">
            	<div class="sidebar-header-wrapper">
            		<!-- Sidebar Collapse -->
	                <div class="sidebar-collapse" id="sidebar-collapse">
	                    <i class="collapse-icon iconfont icon-angle-double-left"></i>
	                </div>
	                <!-- /Sidebar Collapse -->
            	</div>
                <!-- Sidebar Menu -->
                <ef:list method="Application.bindMainMenus">
                	<ul id="_Child_Menu_${ID}" class="nav sidebar-menu" style="display:none">
                		<ef:list method="Application.bindChildMenus">
                  			<li><a class="${List.HasChild?'menu-dropdown':''}" href="${URL}" menuid="${ID}"><i class="menu-icon ${IconCls}"></i>${List.HasChild?'<i class="menu-expand"></i>':''}<span class="menu-text"> ${Name} </span></a>
                  				<ef:if condition="${HasChild}">
              						<ul class="submenu">
	                  					<ef:list method="Application.bindChildMenus">
	                  						<li><a href="${URL}" menuid="${ID}"><span class="menu-text">${Name}</span></a></li>
	                  					</ef:list>
	                    			</ul>
                  				</ef:if>
                  			</li>
                  		</ef:list>
                  	</ul>
                </ef:list>
                <!-- /Sidebar Menu -->
            </div>
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div id="_contentsWrap" class="page-content">
            	<iframe id='_mainContent_0' name="_mainContent_0" frameborder="0" class="animated fadeInRight" width="100%" height="100%" src='about:blank' scrolling="auto" allowtransparency="true" style="left:-22in;top:-11in;"></iframe>
            </div>
            <!-- /Page Content -->
       </div>
        <!-- Main Container -->
    </div>
    <!--Basic Scripts-->
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <!--Beyond Scripts-->
    <script src="vendors/efastsoft/beyond.js"></script>
   <script>
Priv.AdminUserName = "${AdminUserName}";
Priv.UserName = "${User.UserName}";
Priv.init(${(Privs)});
var CurrentApp = "${app}";
</script>
</body>
<!--Basic Styles-->
<link href="framework/css/font.css" rel="stylesheet" />
</html>
</ef:init>